// 拼接sql语句的
let editSqlWords = function editSqlWords (params) {
    let editParams = params.map((item) => {
        return '\'' + item + '\''
    })
    // console.log(editParams);
    // console.log(editParams.toString());
    let editStr = "(" + editParams.toString() + ")" + ","
    return editStr.substring(0, editStr.length - 1)
}

let query = (sql, val) => {
    return new Promise((resolve, reject) => {
        pool.getConnection((err, connection) => {
            if (err) {
                return resolve(err)
            } else {
                connection.query(sql, val, (err, rows) => {
                    if (err) {
                        reject(err)
                    } else {
                        resolve(rows)
                    }
                    connection.release()
                })
            }
        })
    })
}


module.exports = {
    editSqlWords,
    query
}